/*
 * syscall.h
 */

/*
   Copyright 2007 Corey Tabaka

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#ifndef __SYSCALL_H__
#define __SYSCALL_H__

#include <ktypes.h>

/* CAUTION: Don't use these directly. BCC has bugs in how it sizes constants.
 * Use the macros defined below to enforce argument sizes.
 */
uint message_send(pid_t, qid_t, const void *, uint, void *, uint);
uint message_receive(qid_t, void *, uint);
uint message_reply(qid_t, const void *, uint);

uint message_createPipe(void);
void message_destroyPipe(qid_t);

void thread_sleep(uint);
void thread_wait(void);

/* macros to enforce argument sizes */
#define MESSAGE_SEND(p, q, s, sl, d, dl) \
	message_send((long) p, (long) q, (long) s, (long) sl, (long) d, (long) dl)
#define MESSAGE_RECEIVE(q, d, dl) \
	message_receive((long) q, (long) d, (long) dl)
#define MESSAGE_REPLY(q, s, sl) \
	message_reply((long) q, (long) s, (long) sl)

#define CREATE_PIPE			message_createPipe
#define DESTROY_PIPE(q)		message_destroyPipe((long) q)
#define SLEEP(m)			thread_sleep((long) m)
#define WAIT				thread_wait

#endif
